package com.team.lostProperty.controller;

import com.team.lostProperty.entity.*;
import com.team.lostProperty.service.NewPushInfoService;
import com.team.lostProperty.utils.IdWorker;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author duzq
 * @date 2020/07/22 18:49
 **/
@RestController
@RequestMapping("/newPushInfo")
public class NewPushInfoController {
    private IdWorker idWorker=new IdWorker(1,1,1);

    @Resource
    private NewPushInfoService newPushInfoService;

    @RequestMapping("/selectByUser")
    public Result selectByUser(long userId){
        NewPushInfo newPushInfo=new NewPushInfo();
        User user=new User();
        user.setUserId(userId);
        newPushInfo.setUser(user);
        List<NewPushInfo> list=newPushInfoService.selectByUser(newPushInfo);
        Result result=new Result();
        if(list!=null&&list.size()>0){
            result.setMsg("查询成功");
            result.setCode(Result.RESULT_OK);
            result.setData(list.get(0));
            try {
//                newPushInfoService.delete(list.get(0));
            }catch (Exception e){
                result.setMsg("新评论查询失败");
                result.setCode(Result.RESULT_ERROR);
                result.setData("");
            }
        }else{
            result.setMsg("查询成功");
            result.setCode(Result.RESULT_ZERO);
            result.setData("");
        }
        return result;
    }


}
